package Objects;

import org.newdawn.slick.geom.Circle;
import org.newdawn.slick.geom.Shape;

import LBC.CollisionListener;

public class BodyCircle extends Body {	
	public Circle circle;
	public Shape shape;
	
	
	public BodyCircle(int mass, float x, float y, int radius, float velocityX, float velocityY,  float angle, float angularVelocity, float forceX, float forceY, float epsilon) {
		super(mass, velocityX, velocityY, angle, angularVelocity, forceX, forceY, epsilon);
		this.circle=new Circle(x,y,radius);
		super.shape=this.circle;
		this.momentOfInertia=(float)(mass*(Math.pow(radius,2)));
		this.CMX=radius;
		this.CMY=radius;
		this.COR=1;
	}
	public BodyCircle(int mass, float x, float y, int radius){
		super(mass);
		this.circle=new Circle(x,y,radius);
		super.shape=this.circle;
		this.momentOfInertia=(float)(mass*(Math.pow(radius,2)));
		this.CMX=radius;
		this.CMY=radius;
		this.COR=1;
	}
	public void addColisionListener(CollisionListener listener){
		//listener.addBodyC(this);
	}
	
	public float[] getSupportingPoint(float[] u) {
		float [] O={this.circle.getCenterX(),this.circle.getCenterY()};
		float [] result=new float [2];
		float res1=new Float(Math.sqrt(u[0]*u[0]+u[1]*u[1]));
		result[0]=O[0]+this.circle.radius*u[0]/res1;
		result[1]=O[1]+this.circle.radius*u[1]/res1;
		System.out.println("O "+O[0]);
		return result;
	}
	
	public float[] findNormal(float pX, float pY) {
		int X=0;
		int Y=1;
		float []normal={0,0};
		float []vector={0,0};
		vector[X]=pX-this.shape.getCenterX();
		vector[Y]=pY-this.shape.getCenterY();
		float normalV=(float)(Math.sqrt(Math.pow(vector[X],2)+Math.pow(vector[Y],2)));
		normal[X]=vector[X]/normalV;
		normal[Y]=vector[Y]/normalV;
		return normal;
	}
	
		
}
